Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rouge: Add support for resizing raw images #120

Merged
merged 2 commits into from
Oct 28, 2024
Merged

Conversation

Deedone
Copy link
Contributor

@Deedone Deedone commented Oct 26, 2024

Add new "resize" to the raw_image block, which allows rouge to resize the raw_image to the size set in the block.

This is useful when the image size needs to be changed frequently, or multiple images need to be created from the same source files, as it allows to skip the rootfs rebuild step.

Images are copied to a temporary directory before resizing to preserve the original build artifacts. The temporary directory is created in the current working directory to prevent filling the system's /tmp with large images.

@Deedone
Copy link
Contributor Author

Deedone commented Oct 26, 2024

@rshym suggested that we should make resize true by default to make behavior more consistent with the other blocks. Will it be a better approach?

@rshym
Copy link
Contributor

rshym commented Oct 26, 2024

@rshym suggested that we should make resize true by default to make behavior more consistent with the other blocks. Will it be a better approach?

After additional discussion, we agreed that 'resize true by default' is not needed.

I strongly disagree with the statement mentioned above.

Copy link
Collaborator

@lorc lorc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! With that small nit fixed:

Reviewed-by: Volodymyr Babchuk <[email protected]>


fsize = os.path.getsize(self._fname)

if (self._resize and fsize < self._size):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is Python, not C :)
No need for parentheses

@lorc
Copy link
Collaborator

lorc commented Oct 26, 2024

Will it be a better approach?

Yes. I believe in "least surprise" principle. So make it True by default.

@Deedone Deedone force-pushed the raw_resize branch 2 times, most recently from b6018cf to d532bc9 Compare October 28, 2024 08:51
@Deedone
Copy link
Contributor Author

Deedone commented Oct 28, 2024

Also improved the error messaging slightly, I hope it's okay

@rshym
Copy link
Contributor

rshym commented Oct 28, 2024

Reviewed-by: Ruslan Shymkevych <[email protected]>

@@ -93,3 +93,13 @@ def mmd(img: BinaryIO, folders: list):
args.extend(folders)

_run_cmd(args)


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this empty line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is required by python styling guides

ext_utils.resize2fs(os.path.join(tmpd, os.path.basename(self._fname)))
except subprocess.CalledProcessError as e:
log.error(
"%s is not resizable. If you don't need to resize it, set 'resize: false' in the yaml.",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I believe there are multiple reasons why resize2fs may fail.

Thinking of it, this is much more complex task, because raw image could be not only ext2fs, but FAT, for example...

To unblock us, please rewrite the error message like this:

"Failed to resize %s partition. Right now we support resizing for EXT{2,3,4} partitions only. If you don't really want to resize it, please remove "size" parameter or set "resize" to false. If you want to resize some other type of partitions - please create a PR or notify us at least".

Also, please open issue for mouling about this.

Add new "resize" option to the raw_image block, which allows rouge
to resize the raw_image to the size set in the block. It is enabled
by default and can be disabled manually.

This is useful when the image size needs to be changed frequently, or
multiple images need to be created from the same source files, as it
allows to skip the rootfs rebuild step.

Images are copied to a temporary directory before resizing to preserve
the original build artifacts. The temporary directory is created in the
current working directory to prevent filling the system's /tmp with
large images.

Signed-off-by: Mykyta Poturai <[email protected]>
Reviewed-by: Volodymyr Babchuk <[email protected]>
Reviewed-by: Ruslan Shymkevych <[email protected]>
There is a new feature for "rouge" was added. Let's bump moulin
version.

Signed-off-by: Mykyta Poturai <[email protected]>
Reviewed-by: Volodymyr Babchuk <[email protected]>
Reviewed-by: Ruslan Shymkevych <[email protected]>
@lorc lorc merged commit b50a902 into xen-troops:main Oct 28, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants